WordPress for BAE 不使用插件实现评论回复邮件提醒功能

表示这是博主原创。。。转载请注明原文链接
该方法仅限在 BAE 版 WordPress 上使用
当然如果要在普通版本的 WordPress 上实现功能的话,请自行修改 wp_mail 那一行

找到你网站根目录下的 wp-comments-post.php ,在里面找这样一行代码

1
$location = empty($_POST['redirect_to']) ? get_comment_link($comment_id) : $_POST['redirect_to'] . '#comment-' . $comment_id;

在前面加入

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
if (!empty($comment_parent)) {
$get_comment_parent = get_comment($comment_parent);
$mail_subject=$comment->comment_author.' 回复了您的评论 - '.get_option('blogname');
$mail_message='

您在《'.$post->post_title.'》发表的评论内容:
'.
$get_comment_parent->comment_content.'

'.
'

由 '.$comment->comment_author.' 于 '.$comment->comment_date.' 回复您的评论内容:
'.
$comment->comment_content.'

'.
'

点击链接查看或回复:
'.
'['.get_comment_link($comment_id).']('.get_comment_link($comment_id).')

';
if ($comment->comment_author_email !== $get_comment_parent->comment_author_email) {
wp_mail($get_comment_parent->comment_author_email,$mail_subject,''.$mail_message);
}
}

保存,上传覆盖原文件即可